import time


def manu():
    print('=' * 21)
    print('= ' + '欢迎来到好友管理系统' + ' =')
    print('=     ' + '1:添加好友' + '     =')
    print('=     ' + '2:删除好友' + '     =')
    print('=     ' + '3:备注好友' + '     =')
    print('=     ' + '4:展示好友' + '     =')
    print('=     ' + '5:退出系统' + '     =')
    print('=' * 21)

friends = []
def addFriend():
    name = input('请输入您要添加的好友名称：')
    if name in friends:
        print('该好友已存在，添加失败！！！')
        return
    else:
        friends.append(name)
        print("添加好友成功！！！")
    # print('添加好友')
    # pass


def delFriend():
    name = input('请输入您要删除的好友名称：')
    if name not in friends:
        print('该好友不存在，删除失败！！！')
        return
    else:
        friends.remove(name)
        print("删除好友成功！！！")
    # print('删除好友')
    # pass


def updateFriend():
    global friends
    name = input('请输入您要修改备注的好友名称：')
    if name not in friends:
        print('该好友不存在，修改备注失败！！！')
        return
    else:
        nickname = input('请输入你要修改的备注：')
        friendsList = '-'.join(friends)
        friendsList = friendsList.replace(name,nickname)
        friends = friendsList.split('-')
        print("修改备注成功！！！")
    # print('修改好友')
    # pass


def showFriend():
    if len(friends) != 0:
        print(friends)
    else:
        print('当前好友列表为空！！！')
    # print('展示好友')
    # pass


while True:
    manu()
    choice = input('请输入数字1-5进行操作：')
    if choice == '1':
        addFriend()
    elif choice == '2':
        delFriend()
    elif choice == '3':
        updateFriend()
    elif choice == '4':
        showFriend()
    elif choice == '5':
        print('退出好友管理系统')
        time.sleep(3)
        break
    else:
        print('输入信息错误，请重新输入！！！')
